package com.link.base.base.crowd.service;

import com.link.base.base.crowd.dao.mybatis.mapper.CrowdAggrMapper;
import com.link.base.base.crowd.model.CrowdAggr;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.model.BasicModel;
import com.link.core.basic.query.Filter;
import com.link.core.basic.query.QueryParams;
import com.link.core.basic.query.Sorter;
import com.link.core.basic.service.BasicServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 人群一级集合表
 * @author 何启谦
 * @date 2019-02-14
 */
@Service
public class CrowdAggrServiceImpl extends BasicServiceImpl<CrowdAggr> implements CrowdAggrService {

    @Resource
    private CrowdAggrMapper crowdAggrMapper;

    @Override
    public BasicMapper<CrowdAggr> getBasicMapper() {
        return crowdAggrMapper;
    }

    @Override
    public List<CrowdAggr> queryByHeadId(Long crowdId) throws Exception {
        QueryParams qps = new QueryParams();
        qps.setPageFlag(false);
        qps.setTotalFlag(false);
        qps.addFilter(new Filter("crowdId", String.valueOf(crowdId)));
        qps.addSorter(new Sorter("seq", Sorter.DIR_ASC));
        CrowdAggr crowdAggr = (CrowdAggr) BasicModel.transformClass(CrowdAggr.class, qps);
        return queryByExamplePage(crowdAggr);
    }
}

